# https://github.com/kubernetes-sigs/cloud-provider-azure/releases
{{- range $key, $value := .CandiVersionMap.k8s }}
  {{- $version := toString $key }}
  {{- if $value.ccm.azure }}
---
image: {{ $.ModuleName }}/{{ $.ImageName }}-{{ $version | replace "." "-" }}
fromImage: common/distroless
import:
  - artifact: {{ $.ModuleName }}/{{ $.ImageName }}-artifact-{{ $version | replace "." "-" }}
    add: /src/bin/azure-cloud-controller-manager
    to: /usr/local/bin/azure-cloud-controller-manager
    before: setup
docker:
  ENTRYPOINT: ["/usr/local/bin/azure-cloud-controller-manager"]
---
artifact: {{ $.ModuleName }}/{{ $.ImageName }}-artifact-{{ $version | replace "." "-" }}
    {{- if semverCompare ">=1.29" $version }}
from: {{ $.Images.BASE_GOLANG_21_ALPINE }}
    {{- else if semverCompare ">=1.27" $version }}
from: {{ $.Images.BASE_GOLANG_20_ALPINE }}
    {{- else if semverCompare ">=1.25" $version }}
from: {{ $.Images.BASE_GOLANG_19_ALPINE }}
    {{- end }}
git:
  - add: /{{ $.ModulePath }}modules/030-{{ $.ModuleName }}/images/{{ $.ImageName }}/patches
    to: /patches
    stageDependencies:
      install:
        - '**/*'
mount:
  - fromPath: ~/go-pkg-cache
    to: /go/pkg
shell:
  beforeInstall:
    - apk add --no-cache make bash git mercurial patch rsync
  install:
    - mkdir /src
    - cd /src
    - wget https://github.com/kubernetes-sigs/cloud-provider-azure/archive/{{ $value.ccm.azure }}.tar.gz -O - | tar -xz --strip-components=1 -C /src/
    - test -d /patches/{{ $version }} && for patchfile in /patches/{{ $version }}/*.patch ; do patch -p1 < ${patchfile}; done
    - hack/pkg-config.sh > .pkg_config
    - export VERSION={{ $value.ccm.azure }}
    - make bin/azure-cloud-controller-manager
    - chown 64535:64535 /src/bin/azure-cloud-controller-manager
    - chmod 0755 /src/bin/azure-cloud-controller-manager
  {{- end }}
{{- end }}
